<template>
	<view class="" style="background: #FFF;    min-height: 100vh;">
		<view class="mainBox">
			<!-- 列表 -->

			<view class="list" v-for="(item, index) in list" :key="index" @click="toDetails(item)">
				<view class="listText">{{ item.title }}</view>
				<view class="listTime">
					<view>{{ item.create_time }}</view>
					<view>数学文化</view>
				</view>
			</view>
			<view class="listText none" v-if="list.length == 0">未搜索到相关内容</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			value: '',
			list: []
		};
	},

	onLoad(item) {
		console.log(item);
		this.$http({
			url: 'maths/search?title=' + item.item,
			method: 'POST'
		}).then(res => {
			if ((res.code = 200)) {
				this.list = res.data['数学文化'];
				// this.listclick()
			} else {
				uni.showToast({
					title: res.msg || '系统异常,请稍后重试',
					icon: 'none',
					duration: 2000
				});
			}
		});
	},
	mounted() {},
	methods: {
		// 跳到详情
		toDetails(data) {
			console.log(data, '数九');

			let item = {
				createTime: data.create_time,
				title: data.title,
				id: data.id,
				content: data.content
			};
			let currentSite = JSON.stringify(item);
			console.log(currentSite, 'jsonStr--------');
			uni.setStorageSync('questionDetails', currentSite);

			uni.navigateTo({
				// url:"."
				// url: '../mathsdetails/mathsdetails?item=' + currentSite
				url: '../mathsdetails/mathsdetails'
			});
		}
	}
};
</script>

<style lang="scss" scoped>
.mainBox {
	padding: 26rpx 32rpx;

	// 列表

	.list {
		padding: 24rpx;
		height: 156rpx;
		background: #ffffff;
		box-shadow: 0rpx 10rpx 20rpx 0rpx rgba(29, 82, 130, 0.06);
		border-radius: 16rpx;
		display: flex;
		flex-direction: column;
		justify-content: space-between;
		margin-bottom: 24rpx;

		.listText {
			font-size: 32rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #2a3447;
			line-height: 48rpx;
		}

		.listTime {
			font-size: 24rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #7b7e8f;
			line-height: 24rpx;
			display: flex;
			justify-content: space-between;
		}
	}
}

.none {
	text-align: center;
	padding-top: 30vh;
}
</style>
